package com.thwcompany.rabbitMQ.listener;
import com.rabbitmq.client.Channel;
import com.thwcompany.pojo.Mail;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@SuppressWarnings("all")
public class QueueListener1 {
	//生产者-消费者模式，这里配置消费者1号，来监听消息队列myqueue
	@RabbitListener(queues = "myqueue")
	public void displayMail(Mail mail,Channel channel, Message message) throws Exception {
		System.out.println("produce--队列监听器1号收到消息"+mail.toString());
		//消费者1号进行手工确认签收消息
		long deliveryTag = message.getMessageProperties().getDeliveryTag();
		channel.basicAck(deliveryTag,false);
	}
}
